
<?
	   layout("/inc/win_layout.html",{title:sysTitle}){
    ?>

<div class="row" style="min-height: auto;padding-bottom: 20px;">
	<div class="panel">
		<div class="col-lg-12">
			<div class="panel-body pan">
				<form action="#" class="form-horizontal">
					<div class="form-body pal" style="width:auto; height: auto;">

						<div>
							<label for="inputUsername" class="col-md-3 control-label">工作流名称
								<span class='require' id="zhongwenName">*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="nameZh" type="text" class="form-control" onchange="pinYin(this.value)" />
								</div>
							</div>
						</div>


						<div>
							<label for="inputUsername" class="col-md-3 control-label">工作流英文名称
								<span class='require' id="yingwenName">*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="nameEn" type="text" class="form-control" />
								</div>
							</div>
						</div>

						<!-- <div style="width:370px;  margin:0 30px 0 60px; padding-bottom: 15px;">
							<label for="inputUsername" class="col-md-3 control-label">类型
								<span class='require' id="leixing">*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<select id="dictType" class="form-control">
										<option value="-1">请选择</option>
										<option value="1">普通结构(名称-值)</option>
										<option value="2">树形结构</option>
									</select>
								</div>
							</div>
						</div> -->
						
						<!-- <div style="width:370px;  margin:0 30px 0 60px; padding-bottom: 15px;">
							<label for="inputUsername" class="col-md-3 control-label">排序
								<span class='require' id="paixu">*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="sort" type="text" class="form-control" />
								</div>
							</div>
						</div> -->
						
						<div>
							<label for="inputUsername" class="col-md-3 control-label">描述
								<span class='require' id="miaoshu"></span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<textarea id="description" type="text" class="form-control" rows="5" ></textarea>
								</div>
							</div>
						</div>
						
						<!-- <div style="width:370px;  margin:0 30px 0 60px; padding-bottom: 15px;">
							<label for="inputUsername" class="col-md-3 control-label">所属资源库
								<span class='require' id="ziyuanku">*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="classesEn" type="text" class="form-control" />
								</div>
							</div>
						</div> -->
						<div id="showrequire" >
							<label for="inputUsername" class="col-md-3 control-label">所属知识库
								<span class='require' id="paixu">*</span> 
							</label>
							<div class="col-md-9">
								<div class="input-group input-group-sm mbs" >
									<input id="parentclassname" type="text" placeholder="请选择类"  class="form-control" disabled="true"  />
									<span class="input-group-btn"><button id="buttonid" onclick="saveclassZTree()" type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle">选择类..</button></span>		
								</div>
							</div>
						</div>
						<!-- <div style="width:370px;  margin:0 30px 0 60px; padding-bottom: 15px;">
							<label for="inputUsername" class="col-md-3 control-label">状态
								<span class='require' id="zhuangtai">*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="status" type="text" class="form-control" disabled="true"/>
								</div>
							</div>
						</div> -->
						<div>
							<label for="inputUsername" class="col-md-3 control-label">
								<div align="right">状态
									<span class='require' id="zhongwenName">*</span>
								</div>
		                    </label>
							<div class="col-md-7">
								<div class="input-icon" >
									<select id="status" class="form-control">
										<option value="0">未启用</option>
										<option value="1">已启用</option>
									</select>
								</div>
							</div>
						</div>
						
						<!-- <div style="width:370px;  margin:0 30px 0 60px; padding-bottom: 15px;">
							<label for="inputUsername" class="col-md-3 control-label">创建人
								<span class='require' id="chuangjianren">*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="createUser" type="text" class="form-control" />
								</div>
							</div>
						</div> -->
						<!-- <div style="width:370px;  margin:0 30px 0 60px; padding-bottom: 15px;">
							<label for="inputUsername" class="col-md-3 control-label">创建时间
								<span class='require' id="chuangjianshijian">*</span> </label>
							<div class="col-md-9">
								<div class="input-icon">
									<input id="createTime" type="text" class="form-control" />
								</div>
							</div>
						</div> -->
						
						<input id="id" type="hidden" class="form-control" />
						
					</div>	
				</form>
			</div>
		</div>
	</div>
</div>

<?} ?>
<script>
	var index1 = window.parent.getlay();
	var sum = window.parent.getsum();
	$("#id").val(index1);
	$("#sort").val(sum);
	$(function() {
		if (index1 != 0) {
			demo1();
		}
	});
	function Page() {
				if($.trim($("#nameZh").val()).length<1) {
    	        	alert('中文名称不能为空！');
    	        	return null;
    	        }
				if($.trim($("#nameEn").val()).length<1) {
    	        	alert('英文名称不能为空！');
    	        	return null;
    	        }
				if($.trim($("#parentclassname").val()).length<1) {
    	        	alert('必须选择所属资源库！');
    	        	return null;
    	        }
		$.ajax({
			type : "post",
			url : "./workflowAddandUpdate.do",
			data : {
				"id" : index1,
				"nameZh" : $("#nameZh").val(),
				"nameEn" : $("#nameEn").val(),
				"description" : $("#description").val(),
				"classes_en": $("#parentclassname").val(),
				"status" : $("#status").val(),
				//"createUser": $("#createUser").val(),
				//"createTime": $("#createTime").val(),
			},
			dataType : "json",
			async : false,
			success : function(data) {
				var index = parent.layer.getFrameIndex(window.name);
				window.parent.get();
				parent.layer.msg('提交成功');
				parent.layer.close(index);
			},
			error : function(data) {
				alert("请求失败");
			}
		});
	}

	function demo1() {
		$.getJSON('./workflowfindone.do', {
			id : index1
		//向服务端传的参数，此处只是演示
		}, function(res) {
			//此处仅仅是为了演示变化的内容
			$("#nameZh").val(res[0].nameZh);
			$("#nameEn").val(res[0].nameEn);
			$("#description").val(res[0].description);
			$("#parentclassname").val(res[0].classesEn);
			//$("#createUser").val(res[0].createUser);
			//$("#createTime").val(res[0].createTime);
			$("#status").val(res[0].status);
		});
	};

//汉字转拼音
  function pinYin(pinyinName){
		$.ajax({
			type : "post",
			url : "pinYin.do",
			data : {
				"pinYin" : pinyinName,
			},
			async : false,
			dataType : "json",
			success : function(data) {
				if(data[0].length > 32){
					layer.msg('自动转换英文名长度过长!请手动输入！');
					$("#nameEn").val("");
				}else{
					$("#nameEn").val(data);
				}
			},
			error : function(data) {
				alert("请求失败");
			}
		})
		}
//查询类
    function saveclassZTree() {
		parent.layer.open({
			type : 2,
			area : [ '360px', '400px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,
			//move : false,
			title:"选择父节点",
			skin : 'layui-layer-rim', //加上边框
			btn : [ '保存 ', '关闭' ],
			content : ["search-weight-classes-zTree.html?winName="+window.name, 'no'],
			yes : function(index,layer) {	
	   			var iframeWin = parent.window[layer.find('iframe')[0]['name']];
			   iframeWin.save();
			},
			cancel : function(index) {
			}
		});
	};

</script>


